﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        .map {
            position: relative;
            width: 100%;
            height: 750px;
            overflow: hidden;
            border: 1px solid green;
            background-color: #334048;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="map-container">
        <div id="map" class="map" />
    </div>
    <input type="file" class="file" name="User_Img1" id="User_Img3" accept="dxf">

    <script src="Scripts/jquery-3.3.1.js"></script>
    <!--<script src="DarwCad-方案1.js"></script>-->
    <script src="DarwCad.js"></script>
    <script>
        $(function () {
            // 上传图片到服务器可以任选插件，建议要控制下文件大小
            $("#User_Img3").on("change", function () {
                var form = new FormData();
                var data = $(this)[0].files[0];
                form.append("file", data);
                $.ajax({
                    url: '/home/Upload',
                    type: 'post',
                    contentType: false,
                    dataType: 'json',
                    data: form,
                    processData: false,
                    success: function (data) {
                        if (data) {
                            var cadData = JSON.parse(data.Data)
                            console.log(cadData)
                            var mapDxf = getMapDXF('map', $("#map")[0].offsetWidth, $("#map")[0].offsetHeight)
                            mapDxf.init(cadData)
                        }
                    },
                    err: function (jqHXR) {
                        console.log(jqXHR.status);
                    }
                });
            });
        })
    </script>
</body>
</html>
